Skip to main content

Control flow

Control flow statements in Fig are used to control the execution of code based on conditions or loops. Here are some common control flow statements: if Statements

The if statement executes a block of code if a specified condition is true.

let x = 10;

if (x > 5) {
print_str("x is greater than 5");
} else {
print_str("x is not greater than 5");
}

Loop Statements

The loop statement executes a block of code repeatedly until explicitly stopped.

loop {
print_str("Loop forever!");
}